#ifndef CSTATE_H_INCLUDED
#define CSTATE_H_INCLUDED

#include "LON.h"
#include "CGameManager.h"

class CState
{
  public:
    CState(CGameManager * mgr): mgr(mgr)
    {
      device = mgr->getDevice();
      smgr = mgr->getSceneManager();
      env = mgr->getGUIEnv();
      driver = mgr->getDriver();
    }

    virtual void init() = 0;
    virtual void close() = 0;
    virtual void run() = 0;

    virtual void enable() = 0;
    virtual void disable() = 0;


    //! Event Receiving Methods

    //! Keyboard Input
    virtual bool OnKeyDown(EKEY_CODE key)
      { return false; }

    virtual bool OnKeyUp(EKEY_CODE key)
      { return false; }

    //! Called when network packets from server arrived
    virtual void OnServerPacketReceived(Packet *packet) = 0;

    //! Called when network packets from other clients arrived
    virtual void OnClientPacketReceived(Packet *packet) = 0;

    //! Called when mouse is clicked
    virtual bool OnMouseClick()
      { return false; }

    //! Called when a GUI button pressed
    virtual bool OnButtonClick(s32 id)
      { return false; }

    //! Called when other GUI events happens
    virtual bool OnGUIEvent(const SEvent& event)
      { return false; }


    CGameManager    *   getManager() { return mgr; }

    IrrlichtDevice  *   getDevice() { return device; }
    ISceneManager   *   getSceneManager() { return smgr; }
    IGUIEnvironment *   getGUIEnv() { return env; }
    IVideoDriver    *   getDriver() { return driver; }


  protected:
    CGameManager    *mgr;

    IrrlichtDevice  *device;
    ISceneManager   *smgr;
    IGUIEnvironment *env;
    IVideoDriver    *driver;

    IGUITab * parent;
};

#endif // CSTATE_H_INCLUDED
